#include "videorequesttoserver.h"

VideoRequestToServer::VideoRequestToServer(const UserId& userId,
                                           const Ip& userIp, const FriendId& friendId)
{
    m_messageType = MessageType::VideoRequestToServer;
    m_userId = userId;
    m_userIp = userIp;
    m_friendId = friendId;
}

VideoRequestToServer::VideoRequestToServer(const QJsonObject& jsonObj)
{
    m_messageType = static_cast<MessageType>(jsonObj[JsonKey::TYPE].toInt());
    m_userId = jsonObj[JsonKey::USER_ID].toString();
    m_userIp = jsonObj[JsonKey::USER_IP].toString();
    m_friendId = jsonObj[JsonKey::FRIEND_ID].toString();
}

QJsonObject VideoRequestToServer::PackJsonData() const
{
    QJsonObject jsonObj;
    jsonObj[JsonKey::TYPE] = static_cast<int>(m_messageType);
    jsonObj[JsonKey::USER_ID] = m_userId;
    jsonObj[JsonKey::USER_IP] = m_userIp;
    jsonObj[JsonKey::FRIEND_ID] = m_friendId;
    return jsonObj;
}

UserId VideoRequestToServer::getUserId() const
{
    return m_userId;
}

Ip VideoRequestToServer::getUserIp() const
{
    return m_userIp;
}

FriendId VideoRequestToServer::getFriendId() const
{
    return m_friendId;
}
